package com.example.auth.controller;

import com.alibaba.fastjson.JSONObject;
import com.example.annotations.Autowired;
import com.example.annotations.Param;
import com.example.annotations.PostMapping;
import com.example.annotations.RestController;
import com.example.auth.model.UserModel;
import com.example.auth.model.UserModelExt;
import com.example.auth.service.UserModelExtService;
import com.example.auth.service.UserModelService;
import com.example.db.model.IPage;
import com.example.utils.Results;

/**
 * @Classname UserModelExtController
 * @Description TODO
 * @Date 2022/8/1 17:29
 * @Created by XiongXiong
 * @Author: X.I.O
 */
@RestController("/userModel")
public class UserModelExtController {

    @Autowired
    UserModelService userModelService;

    @Autowired
    UserModelExtService userModelExtService;

    @PostMapping(value = "/getusermodel",desc = "获取用户的拓展信息")
    public JSONObject getUserModelExtController(@Param(value = "pageNum",desc = "页码",defalultValue = "1")Integer pageNum,
                                                @Param(value = "pageSize",desc = "条数",defalultValue = "10")Integer pageSize,
                                                @Param(value = "searchParams",required = false)JSONObject object){
        UserModel userModel=userModelService.getUserModel();
        if(object==null){
            object=new JSONObject();
        }
        object.put("uid",userModel.getId());
        IPage<UserModelExt> userModelExtIPage=userModelExtService.page(pageNum,pageSize,object);
        return Results.successLayuiTable(userModelExtIPage);
    }

    @PostMapping(value = "/page",desc = "用户拓展信息分页")
    public JSONObject pageUserModelExtController(@Param(value = "pageNum",desc = "页码",defalultValue = "1")Integer pageNum,
                                                 @Param(value = "pageSize",desc = "条数",defalultValue = "10")Integer pageSize,
                                                 @Param(value = "searchParams",required = false)JSONObject object){
        IPage<UserModelExt> userModelExtIPage=userModelExtService.page(pageNum,pageSize,object);
        return Results.successLayuiTable(userModelExtIPage);
    }
}
